package api

import (
	"github.com/gin-gonic/gin"
	"server/internal/app/serv"
	"server/internal/database"
	"server/internal/pkg/response"
)

// LogApi 管理员日志
var LogApi = new(logApi)

type logApi struct{}

// List 列表
func (logApi) List(c *gin.Context) {
	Db := database.DB         //初始化Db
	Db = Common.Query(Db, c)  //查询构造
	Db = Common.Paging(Db, c) //分页

	//快速搜索
	quickSearch := c.Query("quickSearch")
	if quickSearch != "" {
		Db = Db.Where("title like ?", "%"+quickSearch+"%")
	}

	_, list, total := serv.SystemLog.Reads(Db)

	response.SuccessList(c, list, total)
}

// Detail 单条
func (logApi) Detail(c *gin.Context) {
	id := c.Query("id")

	_, detail := serv.SystemLog.Read(id)

	response.SuccessData(c, detail, "")
}
